<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>华泰信息化管理系统</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<#include "public/css.ftl">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#include "public/header.ftl">
<#include "public/aside.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>企业信息查询</h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li class="active">企业信息查询</li>
            </ol>
        </section>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-body">
                            <div id="toolbar">
                                <form id="customerInfoForm">
                                    <div class="form-inline" role="form">
                                        <b>按条件筛选</b></br>
                                        <div class="form-group">
                                            <table>
                                                <tr>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;行业：</label></td>
                                                    <td style="text-align: left;width: 200px" ><select id="search_industry" style="width: 200px"  class="form-control select2" style="height: 80%;width: 189px" placeholder="行业"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;区域：</label></td>
                                                    <td style="text-align: left;width: 100px"><select id="search_area" style="width: 100px"  class="form-control select2" placeholder="区域" style="height: 80%"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;评级：</label></td>
                                                    <td style="text-align: left;width: 100px"><select class="form-control  select2" style="width: 100px"  id="search_rating"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;财报时间：</label></td>
                                                    <td><select class="form-control select2" id="search_newFinancialTime" style="width: 100px"></select></td>
                                                    <td style="text-align: left;width: 80px"></td>
                                                </tr>
                                            </table>
                                            <div style="height: 5px"></div>
                                            <table>
                                                <tr>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;企业性质：</label></td>
                                                    <td style="text-align: left;width: 200px"><select class="form-control select2" style="width: 200px" id="search_holderType"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;是否否决：</label></td>
                                                    <td style="text-align: left;width: 100px"><select class="form-control select2" style="width: 100px" id="search_isVeto" style="width: 100px"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;是否城投：</label></td>
                                                    <td style="text-align: left;width: 100px"><select class="form-control select2" style="width: 100px"  id="search_isCityInvest"></select></td>
                                                    <td style="text-align: left;width: 80px"><label for="inputEmail3" class="control-label">&nbsp;分数：</label></td>
                                                    <td style="text-align: left;width: 200px"><input type="text" class="form-control" style="width: 90px"
                                                                                                     placeholder="最小值" id="search_minScore"/>
                                                        -<input type="text" class="form-control" style="width: 90px" placeholder="最大值" id="search_maxScore"/></td>
                                                    <td style="text-align: left;width:200px">
                                                        <button type="button" class="btn btn-primary" onclick="customerInfoTable_search(1)">查询</button>
                                                        <input type="reset" form="customerInfoForm" class="btn btn-warning" onclick="resetForm(1)" ></div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <div style="height: 5px"></div>
                                    <div class="form-inline" role="form">
                                        <b>按名称搜索</b></br>
                                        <div class="form-group">
                                            <select id="search_custId" class=" form-control select2"
                                                    style="width: 300px">
                                            </select>
                                        </div>
                                        <button type="button" class="btn btn-primary"
                                                onclick="customerInfoTable_search(2)">查询
                                        </button>
                                        <input type="reset" form="customerInfoForm" class="btn btn-warning" onclick="resetForm(2)" >
                                    </div>
                                    </br>
                                </form>
                            </div>

                            <table id="customerInfoTable" class=".table-responsive table text-nowrap"  data-toggle="table"
                                   data-query-params="queryParams" data-url="/companyscore/list"  data-search="true"  data-sortable="true"
                                   data-pagination="true" data-toolbar="#toolbar" data-sort-name="newFinancialTime" data-sort-order="desc" data-unique-id="id" >
                                <thead>
                                <tr>
                                    <th data-field="id" data-formatter="indexFormatter">序号</th>
                                    <th data-field="custName">企业名称</th>
                                    <th data-field="newScore" data-sortable="true" data-align="center" data-formatter="scoreFormatter">最新评分</th>
                                    <th data-field="newFinancialTime" data-sortable="true" data-align="center" data-formatter="financialTimeFormatter">财报时间</th>
                                    <th data-field="industry" data-sortable="true" data-align="center">主营行业</th>
                                    <th data-field="area" data-sortable="true" data-align="center">区域</th>
                                    <th data-field="rating" data-sortable="true" data-align="center">评级</th>
                                    <th data-field="holderType" data-align="center">企业性质</th>
                                    <th data-field="isCityInvest" data-align="center" data-formatter="isCityInvestFormatter">是否城投</th>
                                    <th data-field="newTotalAsset" data-sortable="true"  data-align="right"  data-formatter="dataFormatter">总资产（亿元）</th>
                                    <th data-field="newNetAsset" data-sortable="true" data-align="right" data-formatter="dataFormatter">净资产（亿元）</th>
                                    <th data-field="newRevenue" data-sortable="true" data-align="right" data-formatter="dataFormatter">营业收入（亿元）</th>
                                    <th data-field="aa6" data-formatter="aaFormatter" data-align="center">简评</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
<#include "public/footer.ftl" >
    <div class="control-sidebar-bg"></div>
</div>
<#include "public/tip.ftl">
<#include "public/js.ftl" >
<script src="plugins/chartjs/Chart.bundle.js"></script>
<script src="plugins/chartjs/utils.js"></script>
<script src="plugins/bootstrap3-editable/js/bootstrap-editable.js"></script>
<#include "score/briefevaluate.ftl" >
<script>
    init1();
    init2();

    function init1() {
        var url2 = "/companyscore/select/industry";
        var url3 = "/companyscore/select/area";
        var url4 = "/companyscore/select/rating";
        var url5 = "/companyscore/select/holderType";
        var url6 = "/companyscore/select1/boolean";
        var url7 = "/companyscore/select3/financialtime";
        setFormValue(url2,"search_industry");
        setFormValue(url3,"search_area");
        setFormValue(url4,"search_rating");
        setFormValue(url5,"search_holderType");
        setFormValue(url6,"search_isVeto");
        setFormValue(url6,"search_isCityInvest");
        setFormValue(url7,"search_newFinancialTime");
    }

    function init2() {
        var url1 = "/companyscore/select1/customerInfoVos";
        setFormValue(url1,"search_custId");
    }
    function resetForm(type) {
        if(1 == type) {
            $("#search_industry").empty() ;
            $("#search_area").empty() ;
            $("#search_rating").empty() ;
            $("#search_isVeto").empty() ;
            $("#search_isCityInvest").empty() ;
            $("#search_holderType").empty() ;
            $("#search_minScore").val("");
            $("#search_maxScore").val("");
            $("#search_newFinancialTime").empty() ;
            init1();
        } else {
            $("#search_custId").empty() ;
            init2();
        }
        customerInfoTable_search(3);
    }

//    function setFormValue(url,field) {
//        getReq(url, function (result) {
//            $("#"+field).append("<option>请选择</option>") ;
//            for(var i=0;i<result.length;i++){
//                $("#"+field).append("<option value='"+result[i].value+"'>"+result[i].name+"</option>") ;
//            }
//            $("#"+field).select2();
//        }) ;
//    }

    var queryParams = function () {
        return {};
    };

    function queryParams1() {
        return {
            industry: $("#search_industry").val(),
            area: $("#search_area").val(),
            rating: $("#search_rating").val(),
            isVeto: $("#search_isVeto").val(),
            isCityInvest: $("#search_isCityInvest").val(),
            holderType: $("#search_holderType").val(),
            minScore: $("#search_minScore").val(),
            maxScore: $("#search_maxScore").val(),
            newFinancialTime: $("#search_newFinancialTime").val()
        }
    }

    function queryParams2() {
        return {
            id: $("#search_custId").val()
        }
    }


    function customerInfoTable_search(index) {
        if (index == 1) {
            queryParams = queryParams1();
        } else if (index == 2) {
            queryParams = queryParams2();
        } else if (index == 3) {
            queryParams = null;
        }
        $("#customerInfoTable").bootstrapTable("refresh");
        queryParams = null;
    }

    $(".select2").select2();

    function dataFormatter(value, row, index) {
        if (value != "" && value != undefined)
            return number_format(value, 0);
    }

    function isCityInvestFormatter(value, row, index) {
        if (value == "0") {
            return "否";
        } else if (value == "1") {
            return "是";
        }
        return value;
    }
    function scoreFormatter(value, row, index) {
        return number_format(value,0) ;
    }
    function aaFormatter(value, row, index) {
        return "<a href='#' onclick='showBriefevaluateModal(" + index + ")'>简评详情</a>";
    }

    function showBriefevaluateModal(index) {
        briefevaluateModal_init();
        briefevaluateModal_setValue(index);
        $("#briefevaluateModal").modal("show");
    }

    function financialTimeFormatter(value, row, index) {
        if (value == null || value == "")
            return value;
        return value.substring(0, 4) + "年";
    }

    function isVetoFormatter(value, row, index) {
        if (value == "0") {
            return "否";
        } else if (value == "1") {
            return "是";
        }
        return value;
    }
</script>
</body>
</html>
